package com.tom.baselibrary.ioc;

import android.app.Activity;
import android.view.View;

import androidx.fragment.app.Fragment;

/**
 * Added by Tom on 2024/06/24.
 * View的 findViewById 辅助类。
 */
public class ViewFinder {
    private Activity mActivity;
    private View mView;

    public ViewFinder(Fragment fragment) {
        this.mActivity = null;
    }
    public ViewFinder(Activity activity) {
        this.mActivity = activity;
    }
    public ViewFinder(View view) {
        this.mView = view;
    }

    // 兼容方法
    public View findViewById(int viewId) {
        return mActivity != null ? mActivity.findViewById(viewId) : mView.findViewById(viewId);
    }
}
